import java.time.LocalDate;

public class YesterDate {

    public static String getPreviousDate(int year, int month, int day) {
        if (!isValidDate(year, month, day)) {
            throw new IllegalArgumentException("Invalid date");
        }

        LocalDate date = LocalDate.of(year, month, day);
        LocalDate previousDate = date.minusDays(1);
        return previousDate.toString();
    }

    private static boolean isValidDate(int year, int month, int day) {
        if (year < 1900 || year > 2050) return false;
        if (month < 1 || month > 12) return false;
        if (day < 1 || day > 31) return false;

        // Check for months with fewer than 31 days
        if ((month == 4 || month == 6 || month == 9 || month == 11) && day > 30) return false;
        if (month == 2) {
            if (isLeapYear(year)) {
                return day <= 29;
            } else {
                return day <= 28;
            }
        }
        return true;
    }

    private static boolean isLeapYear(int year) {
        return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
    }
}